package com.cw1.factory.simpleFactory.factory;

import com.cw1.factory.factoryMethod.pizzastore.constant.PizzaConstant;
import com.cw1.factory.simpleFactory.pizza.ChessPizza;
import com.cw1.factory.simpleFactory.pizza.GreekPizza;
import com.cw1.factory.simpleFactory.pizza.PepperPizza;
import com.cw1.factory.simpleFactory.pizza.Pizza;

/**
 * @Author qiuMi
 * @description 披萨 - 简单工厂模式
 * @Date 2022-10-06 23:04
 **/
public class SimpleFactory {
    public Pizza createPizza(String type){
        Pizza pizza = null;
        switch (type){
            case PizzaConstant.CHESS:
                pizza = new ChessPizza();
                pizza.setName("切丝披萨");
                break;
            case PizzaConstant.GREEK:
                pizza = new GreekPizza();
                pizza.setName("希腊披萨");
                break;
            case PizzaConstant.PEPPER:
                pizza = new PepperPizza();
                pizza.setName("胡椒披萨");
                break;
            default:
                pizza = null;
        }
        return pizza;
    }
}
